package jgl.vajra.kingkong.widget.retrofithelper.rxexception;

import android.text.TextUtils;

/**
 * Created by Administrator on 2016/11/24 0024.
 */
public class HttpErrorBundle implements ErrorBundle {
    private static final String DEFAULT_ERROR_MSG = "Unknown error";
    private Exception e;
    private String jsonData;
    private int code;

    public HttpErrorBundle(Exception e, String jsonData, int code) {
        this.e = e;
        this.jsonData = jsonData;
        this.code = code;
    }

    @Override
    public Exception getException() {
        return e;
    }

    @Override
    public String getMessage() {
        String message = e.getMessage();
        return message == null || TextUtils.isEmpty(message) ? DEFAULT_ERROR_MSG : message;
    }

    public String getServerData() {
        return jsonData;
    }
}
